package com.cfkj.vip.function.impl;

import static com.cfkj.common.SystemUtil.*;

import com.cfkj.common.SystemException;
import com.cfkj.vip.dao.UserDao;
import com.cfkj.vip.entity.UserEntity;
import com.cfkj.vip.function.UserFunction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: CFli
 * @Date: 2018/8/14 11:40
 * @Description:
 */
@Service
public class UserFunctionImpl implements UserFunction{
    @Autowired
    UserDao userDao;
    @Override
    public UserEntity login(String account, String password) throws Exception {
        account =$("账号不能为空",account);
        password=$("密码不能为空",password);
        UserEntity en =userDao.select("account",account);
        if(en==null){
            throw new SystemException("账户不存在");
        }
        System.out.println(en.getAccount()+"======"+password);
        if(!en.getPassword().equals(password)){
            throw new SystemException("密码错误");
        }
        return en;
    }
}
